import 'package:flutter/material.dart';
import 'package:flutter_demo/start_up/function_widgets/alerts/0x00_aleret_item.dart';
import 'package:flutter_demo/start_up/function_widgets/alerts/0x01_alert_dialog_routes.dart';

class BottomSheetsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {


    Future<int> _showModalBottomSheet() {
      return showModalBottomSheet<int>(
        context: context,
        builder: (context) {
          return ListView.builder(
            itemCount: 30,
            itemBuilder: (context, index) {
              return ListTile(
                title: Text("$index"),
                onTap: () {
                  Navigator.of(context).pop(index);
                },
              );
            },
          );
        },
      );
    }




    PersistentBottomSheetController<int> _showBottomSheet() {
      return showBottomSheet<int>(
        context: context,
        backgroundColor: Colors.black12,
        builder: (context) {
          return ListView.builder(
            itemCount: 30,
            itemBuilder: (context, index) {
              return ListTile(
                title: Text("$index"),
                onTap: () {
                  Navigator.of(context).pop();
                },
              );
            },
          );
        },
      );
    }





    return Scaffold(
      appBar: AppBar(
        title: Text("Bottom Sheet"),
      ),
      body: Padding(
        padding: EdgeInsets.only(
          top: 18,
          bottom: 18
        ),
        child: ListView(
          children: <Widget>[
            AlertItem("Modal Bottom Sheet", () async {
              int _type = await _showModalBottomSheet();
              alert(context, content: "$_type");
            }),
            AlertItem("Show Bottom Sheet", () {
              _showBottomSheet();
            })
          ],
        ),
      ),
    );
  }
}